﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TireService.Data;

namespace TireService.Mobile
{
    public partial class ServiceBooking : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack != true)
            {
                txtDate.Text = DateTime.Now.ToShortDateString();

                TireServiceDB db = new TireServiceDB();

                ddlServiceCar.DataSource = db.GetServiceCars();
                ddlServiceCar.TextField = "Description";
                ddlServiceCar.ValueField = "ServiceCarId";
                ddlServiceCar.DataBind();
            }
        }

        protected void btnShowSchedule_Click(object sender, EventArgs e)
        {
            TireServiceDB db = new TireServiceDB();

            gvServiceSchedule.DataSource = db.ServiceCarScheduleDetailViews.Where(p => p.ServiceCarId == Convert.ToInt32(ddlServiceCar.SelectedItem.Value) & p.ScheduleDate == Convert.ToDateTime(txtDate.Value)).OrderBy(p => p.SequenceNumber).ToList();
            gvServiceSchedule.DataBind();
        }
    }
}